<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="数据表名" prop="tableName">
        <el-input
          v-model="queryParams.tableName"
          placeholder="请输入数据表名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        > -->
      </el-form-item>
    </el-form>
    <el-table
      class="tb-edit"
      highlight-current-row
      :data="tableData"
      border
      style="width: 100%"
      :height="600"
      @sort-change="handleSortChange"
    >
      <template v-for="col in cols">
        <el-table-column :prop="col.field_name" align="center" sortable>
          <template v-slot:header>
            <span>
              {{ col.comment }}
            </span>
            <i class="el-icon-caret-bottom"></i>
          </template>
        </el-table-column>
      </template>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.page"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
  </div>
</template>  
  
<script>
import {
  listBiRuleSpecifications,
  getBiRuleSpecifications,
  delBiRuleSpecifications,
  addByRuleTage,
  updateBiRuleSpecifications,
  RuleTagger,
  getTablefieldsWithComments,
  bitableoperation,
} from "@/api/conf/BiRuleSpecifications";
export default {
  data() {
    return {
      total: 0,
      // 查询参数
      queryParams: {
        page: 1,
        size: 10,

        tableName: "bi_rule_specifications",
      },
      cols: [],
      tableData: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      let obj = {
        params: this.queryParams,
        data: null,
      };
      bitableoperation(obj).then((response) => {
        this.cols = response.cols ? response.cols : [];
        this.tableData = response.tableData ? response.tableData : [];
        this.total = response.total;
      });
    },
    handleSortChange(column) {
      /**
  排序方向 asc 升序 desc 降序
 
private String orderDirection;*/
      switch (column.order) {
        case "ascending":
          this.queryParams.sortDirection = "asc";
          break;
        case "descending":
          this.queryParams.sortDirection = "desc";
          break;
        default:
          this.queryParams.isAsc = null;
          break;
      }
      this.queryParams.orderBy = column.prop; //查询字段是表格中字段名字
      // this.queryParams.orderDirection = column.order;//动态取值排序顺序

      this.getList();
    },
    /** 翁绍鸿:
orderBy 字段名字 

翁绍鸿:
sortDirection=desc：数据按降序排列。
sortDirection=asc：数据按升序排列。
搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
  },
};
</script>